<?php



class RSS {


function Get($channel, $items) {

    //RSS Begin
    $rss = '<?xml version="1.0" encoding="UTF-8"?>'."\r\n";
    $rss .= '<rss version="2.0">'."\r\n";
    $rss .= '<channel>'."\r\n";
    $rss .= '<title>'.$channel["title"].'</title>'."\r\n";
    $rss .= '<link>'.$channel["link"].'</link>'."\r\n";
    $rss .= '<image>'.$channel["image"].'</image>';
    $rss .= '<description>'.$channel["description"].'</description>'."\r\n";

    foreach($items as $item) {
        $id = '';
        $description = '';
        $pubDate = '';
        $text = '';
        $image = '';
        $name = '';
        $screen_name = '';
        $link = '';
        $guid = '';
        $source = '';
        $category = '';

        $id = $item["id"];
        $title = $item["title"];
        $pubDate = $item["pubDate"];
        $pubDate = date('D, d M Y g:i a e', strtotime($pubDate));
        $text = $item["description"];
        $source = $item["source"];
 
        //Item       
        $rss .= '<item>';
        $rss .= '<title><![CDATA['.$title.']]></title>'."\r\n";
        $rss .= '<pubDate>'.$pubDate.'</pubDate>'."\r\n";
        $link = 'http://www.twitter.com/'.$screen_name.'/statuses/'.$id;
        $guid = $link;
        $rss .= '<link><![CDATA['.$link.']]></link>'."\r\n";
        $rss .= '<guid><![CDATA['.$guid.']]></guid>'."\r\n";
        $rss .= '<author>'.$name.'</author>';
        if(!empty($friends[$screen_name]))
        {
            $category = $friends[$screen_name];
        }
        $rss .= '<category>'.$category.'</category>';
        $rss .= '<description><![CDATA[<a href="http://www.twitter.com/'.$screen_name.'"><img alt="'.$name.'" src="'.$image.'" /></a> ';
        $rss .= '<strong><a href="http://www.twitter.com/'.$screen_name.'" title="'.$name.'">'.$screen_name.'</a></strong> ';
        //$rss .= makeClickableLinks($text).' ';
        $rss .= $text.' ';
        $rss .= '<a href="'.$link.'">'.$pubDate.'</a>';
        $rss .= ' from '.$source.' ';
        $rss .= '<p><a href="http://twitter.com/home?status=@'.urlencode($screen_name).'">Reply</a> ';
        $rss .= '| <a href="http://twitter.com/home?status=D '.urlencode($screen_name).'">Direct Message</a> ';
        $rss .= '| <a href="http://twitter.com/home?status=">Update Status</a>';
        $rss .= ']]></description>'."\r\n";
        $rss .= '</item>'."\r\n";
    }

    //End RSS
    $rss .= '</channel>'."\r\n".'</rss>'."\r\n";

    return $rss;
    }

}

?>